Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

psp-7209 do not display acquisition file until all loading state is c… #3580

Merged
merged 1 commit into from
Nov 8, 2023

Conversation

devinleighsmith
Copy link
Collaborator

…omplete and context is initialized.

@devinleighsmith devinleighsmith added the bug Something isn't working label Nov 8, 2023
@devinleighsmith devinleighsmith self-assigned this Nov 8, 2023
if (
loadingAcquisitionFile ||
(loadingAcquisitionFileProperties && !isPropertySelector) ||
file?.fileType !== FileTypes.Acquisition ||
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is odd. Do you know when this would be true?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, so essentially there is a race condition where when the file is loading the previous file is still in context. The state transition to set loading to false occurs before the new file is set into the context, and so this occurs.

Another solution would be to set the file in the context to null immediately during load.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bug happens when you load a Research file into the sidebar (which populates the sidebar context), then without closing the sidebar go to an ACQ file (via the PIMS files tab of a property of the file). Then the container renders what is already in context thinking it is an ACQ file when it is not.

Copy link
Contributor

github-actions bot commented Nov 8, 2023

✅ No secrets were detected in the code.

Comment on lines -79 to -81
if (!!file && file?.fileType !== FileTypes.Acquisition) {
throw Error('Context file is not an acquisition file');
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually think this is a good error check. Without it we would have never found this bug/race condition. Just my opinion, but I would actually like to see this restored and a similar check added to ResearchView - but we can discuss on our Friday meeting

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we leave it in, it would be dead code, because the parent makes the same check. This if statement will never run with the recommended changes.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, in theory this view could be embedded "anywhere" by another container but as I said would like us to discuss this use case for other views that make use of a context that might not have the information the view is expecting

Copy link

codecov bot commented Nov 8, 2023

Codecov Report

Merging #3580 (2efbd0a) into dev (f67bcdd) will increase coverage by 5.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev    #3580      +/-   ##
==========================================
+ Coverage   69.57%   74.59%   +5.02%     
==========================================
  Files        1371      898     -473     
  Lines       33859    18612   -15247     
  Branches     6290     5258    -1032     
==========================================
- Hits        23557    13884    -9673     
+ Misses      10049     4728    -5321     
+ Partials      253        0     -253     
Flag Coverage Δ
unittests 74.59% <100.00%> (+5.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...es/mapSideBar/acquisition/AcquisitionContainer.tsx 90.43% <100.00%> (+0.34%) ⬆️
...eatures/mapSideBar/acquisition/AcquisitionView.tsx 49.05% <ø> (-0.04%) ⬇️

... and 473 files with indirect coverage changes

@devinleighsmith devinleighsmith merged commit b70b3f4 into bcgov:dev Nov 8, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants